<?php

class faculty_Model_DbTable_DbFac extends Zend_Db_Table_Abstract
{

    protected $_name = 'tbl_faculty';
	//function for getting record user by user_id
    public function selectfac(){
    	$db = new Application_Model_DbTable_DbGlobal();
    	//$db = $this->getAdapter();
    	$sql = "SELECT * FROM tbl_faculty";
    	return $db->getGlobalDb($sql);
    }
    public function getfac($id){
    	$db = $this->getAdapter();
    	$sql = "Select * From tbl_faculty where fac_id =".$id." LIMIT 1";
    	$rows = $db->fetchRow($sql);
		return $rows;
    }
	public function insertFac($arr)
	{ 
     	$array_data = array(
     			"fac_id"	=>	$arr["fac_id"],
     			"fac_name"		=>	$arr["fac_name"],  
     			"ordering"		=>	$arr["ordering"],
     			"description"	=>	$arr["description"],
     			"status"	=>	1,
     			"created_date"	=>	date("Y-m-d H:i:s")
     			);
     	$id=$this->insert($array_data);

	}
	public function updateStatus($arr)
	{
			$array_data = array(
				"fac_id"	=>	$arr["fac_id"],
				"status"	=>	1     			   			
     			);
			$where = $this->getAdapter()->quoteInto('fac_id=?', $arr["fac_id"]);
			//echo $where; exit();
			$this->update($array_data, $where);
			
	}
	public function updateUnStatus($arr)
	{
		$array_data = array(
				"fac_id"	=>	$arr["fac_id"],
				"status"	=>	0
		);
		$where = $this->getAdapter()->quoteInto('fac_id=?', $arr["fac_id"]);
		//echo $where; exit();
		$this->update($array_data, $where);
			
	}
	public function updateFac($arr)
	{
		$array_data = array(
				"fac_id"	=>	$arr["fac_id"],
				"fac_name"		=>	$arr["fac_name"],
				"ordering"		=>	$arr["ordering"],
				"description"	=>	$arr["description"],
				"created_date"	=>	date("Y-m-d H:i:s")
		);
		$where = $this->getAdapter()->quoteInto('fac_id=?', $arr["fac_id"]);
		$this->update($array_data, $where);
		//echo $where; exit();
	}
	public function deletefac($id){
		$db = $this->getAdapter();
		$sql = "Delete From tbl_faculty Where fac_id=".$id;
		$row = $db->query($sql);
		return $row;
	}

}

